﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gr_Erp_Api_AECloud;
using Gr_Erp_Api_AECloud.ReturnModel;

namespace AECloud_Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string table = this.textBox1.Text.Trim();
            string condition = this.textBox2.Text.Trim();
            int limit = Convert.ToInt32(this.textBox3.Text.Trim());
            int skip = Convert.ToInt32(this.textBox4.Text.Trim());
            string sort = this.textBox5.Text.Trim();
            AEHttp http = new AEHttp();
            ReturnModelForAll response = http.Find(table, condition, limit, skip, sort);

            this.textBox6.Text = response.Errno;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string table = this.textBox1.Text.Trim();
            string condition = this.textBox2.Text.Trim();
            int limit = Convert.ToInt32(this.textBox3.Text.Trim());
            int skip = Convert.ToInt32(this.textBox4.Text.Trim());
            string sort = this.textBox5.Text.Trim();
            AEHttp http = new AEHttp();
            string response = http.First(table, condition, limit, skip, sort);

            this.textBox6.Text = response;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string table = this.textBox1.Text.Trim();
            string id = this.textBox2.Text.Trim();
            AEHttp http = new AEHttp();
            ReturnModelForAll _ReturnModelForAll = http.Get(table, id);

            this.textBox6.Text = _ReturnModelForAll.Errno;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            string table = this.textBox1.Text.Trim();
            string id = this.textBox2.Text.Trim();
            AEHttp http = new AEHttp();
            string response = http.Remove(table, id);

            this.textBox6.Text = "删除" + response + "条";
        }

        private void button5_Click(object sender, EventArgs e)
        {
            string table = this.textBox1.Text.Trim();
            string condition = this.textBox2.Text.Trim();
            AEHttp http = new AEHttp();
            string response = http.Clear(table, condition);

            this.textBox6.Text = "删除" + response + "条";
        }

        private void button6_Click(object sender, EventArgs e)
        {
            string table = this.textBox1.Text.Trim();
            string row = this.textBox2.Text.Trim();
            AEHttp http = new AEHttp();
            ReturnModelForAll response = http.Create(table, row);

            this.textBox6.Text = "增加" + response + "条";
        }

        private void button7_Click(object sender, EventArgs e)
        {
            string table = this.textBox1.Text.Trim();
            string condition = this.textBox2.Text.Trim();
            string row = this.textBox7.Text.Trim();
            AEHttp http = new AEHttp();
            ReturnModelForAll response = http.Update(table, condition, row);

            this.textBox6.Text = "更新" + response.Errno + 1 + "条";
        }

        private void button8_Click(object sender, EventArgs e)
        {
            //string table = this.textBox1.Text.Trim();
            //string condition = this.textBox2.Text.Trim();
            //AEHttp http = new AEHttp();
            //string response = http.Count(table, condition);

            //this.textBox6.Text = "共计" + response + "条";
        }
    }
}
